package cn.coisini.api.admin;

import cn.coisini.model.common.dtos.Result;
import cn.coisini.model.common.enums.ResultEnum;
import cn.coisini.model.dto.CategoryDto;
import cn.coisini.model.pojo.Category;
import cn.coisini.model.vo.CategoryVo;
import cn.coisini.model.vo.QueryVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author xiangshaw
 * Description: 分类接口API
 */
@Tag(name = "分类接口API", description = "新增、查询、修改、删除")
@RequestMapping("/api/v1/category")
@Validated
public interface CategoryControllerApi {

    @Operation(summary = "新增分类接口")
    @PreAuthorize("hasAuthority('category:add')")
    @PostMapping("/add")
    Result<ResultEnum> addCategory(
            @RequestBody
            @Validated({CategoryDto.Add.class})
            CategoryDto categoryDto);

    @Operation(summary = "查询分类列表接口")
    @PreAuthorize("hasAuthority('category:list')")
    @GetMapping("/list")
    Result<Object> getCategoryList(QueryVo queryVo);

    @Operation(summary = "查询分类列表接口")
    @GetMapping("/articleList")
    Result<List<Category>> getArticleCategoryList();

    @Operation(summary = "修改分类接口")
    @PreAuthorize("hasAuthority('category:update')")
    @PutMapping("/update")
    Result<ResultEnum> updateCategory(
            @RequestBody
            @Validated({CategoryDto.Update.class})
            CategoryDto categoryDto);

    @Operation(summary = "删除分类接口")
    @PreAuthorize("hasAuthority('category:delete')")
    @DeleteMapping("/delete")
    Result<ResultEnum> deleteCategory(CategoryVo categoryVo);

    @Operation(summary = "批量删除分类接口")
    @PreAuthorize("hasAuthority('category:batchRemove')")
    @DeleteMapping("/deleteByIds")
    Result<ResultEnum> deleteCategoryByIds(@RequestBody CategoryVo categoryVo);
}
